package com.example.fundamentallibrary

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.annotation.LayoutRes
import com.trello.rxlifecycle4.components.RxFragment

abstract class BaseMvpFragment: RxFragment() {
    protected var rootView: View? = null

    override fun onCreateView(
        inflater: LayoutInflater?,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        if (rootView == null) {
            rootView = inflater?.inflate(getLayoutId(), container, false)
            init(savedInstanceState)
        }
        return rootView
    }

    @LayoutRes
    protected abstract fun getLayoutId(): Int

    protected fun init(savedInstanceState: Bundle?){}
}